﻿@{
    Layout = null;
}

<form id="form_AllotCodeAdd" role="form" class="form-horizontal" onkeydown="if(event.keyCode==13){return false;}">
    <div class="form-group">
        <div class="col-xs-2 col-md-2 text-right">
            <span class="red-700">*</span>
            分往机构:
        </div>
        <div class="col-xs-10 col-md-10">
            <select id="DirectSubLevel" name="DirectSubLevel" onchange="$.MGJ.AllotCode.GetProductByEnterprise()" class="form-control">
                @*<option value="0">--请选择--</option>*@
            </select>
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-2 col-md-2 text-right">
            应用产品:
        </div>
        <div class="col-xs-10 col-md-10">
            <select id="ProductSelect" class="form-control">
                <option value="0">--请选择--</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-2 col-md-2 text-right">
            应用品牌:
        </div>
        <div class="col-xs-4 col-md-4">
            <input type="text" name="Brand" class="form-control" placeholder="请输入应用品牌" />
        </div>

        <div class="col-xs-2 col-md-2 text-right">
            产品规格:
        </div>
        <div class="col-xs-4 col-md-4">
            <input id="ProductSize" type="text" name="ProductSize" class="form-control" placeholder="请输入产品规格" />
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-2 col-md-2 text-right">
            分配方式：
        </div>
        <div class="col-xs-2 col-md-2">
            <button type="button" id="ByCodeNum" onclick="$.MGJ.AllotCode.ByCodeNum($.MGJ.AllotCode.SetAllotType(0))" class="btn btn-default active">号段</button>
        </div>
        <div class="col-xs-2 col-md-2 text-right">
            <button type="button" id="ByFullPage" onclick="$.MGJ.AllotCode.ByFullPage($.MGJ.AllotCode.SetAllotType(1))" class="btn btn-default">整批</button>
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-2 col-md-2 text-right">
            <span class="red-700">*</span>
            生码批次:
        </div>
        <div class="col-xs-4 col-md-4">
            <select id="GenCodeBatch" name="GenCodeBatch" class="form-control" onchange="$.MGJ.AllotCode.onBatchChange()"></select>
        </div>
        <input type="hidden" id="HidCount" value="0" />
    </div>

    <div id="NeedStatEndCode">
        <div class="form-group">
            <div class="col-xs-2 col-md-2 text-right">
                <span class="red-700">*</span>
                起始码
            </div>
            <div class="col-xs-4 col-md-4">
                <input type="text" id="StartCode" name="StartCode" class="form-control" placeholder="请输入起始号" oninput="scanf_integral (event)" />
            </div>

            <div class="col-xs-2 col-md-2 text-right">
                <span class="red-700">*</span>
                结束码
            </div>
            <div class="col-xs-4 col-md-4">
                <input type="text" id="EndCode" name="EndCode" class="form-control" placeholder="请输入结束号" oninput="scanf_integral (event)" />
            </div>
        </div>
        <div class="form-group">
            <div class="col-xs-2 col-md-2 text-right">
                已选数量:
            </div>
            <div class="col-xs-8 col-md-8">
                <input type="text" id="AllotCount" name="AllotCount" class="form-control" readonly="readonly" />
            </div>

            @*<div class="col-xs-4 col-md-4">
                    <select class="form-control">
                        <option value=""></option>
                    </select>
                </div>*@
            （单标）
        </div>
    </div>
    <div id="NeedStatEndCode2" style="display:none;">
        <div class="form-group">
            <div class="col-xs-2 col-md-2 text-right">
                已选数量:
            </div>
            <div class="col-xs-8 col-md-8">
                <input type="text" id="AllotCount2" name="AllotCount" class="form-control" readonly="readonly" />
            </div>

            @*<div class="col-xs-4 col-md-4">
                    <select class="form-control">
                        <option value=""></option>
                    </select>
                </div>*@
            （单标）
        </div>
    </div>
</form>
<script type="text/javascript">
    /*初始加载当前企业直属机构及批次*/
    $.MGJ.AllotCode.GetCurrentEnterpriseDirectSubLevel();
    $.MGJ.AllotCode.GetBatchList(0);
</script>
<script>
    //起始码结束码
    function scanf_integral() {
        var StartCode = $("#StartCode").val();
        var EndCode = $("#EndCode").val();
        if (StartCode != '' && EndCode != '') {
            $("#AllotCount").val(parseInt(EndCode) - parseInt(StartCode) + 1)
        }
    }

    $(function () {
        $('#form_AllotCodeAdd').bootstrapValidator({
            fields: {
                DirectSubLevel: {
                    validators: {
                        notEmpty: {
                            message: '暂无分往机构'
                        }
                    }
                },
                Brand: {
                    validators: {
                        regexp: {
                            regexp: /^[a-zA-Z0-9\u4e00-\u9fa5]+$/,
                            message: '应用品牌不能输入符号'
                        }
                    }
                },
                ProductSize:{
                    validators: {
                        regexp: {
                            regexp: /^[a-zA-Z0-9\u4e00-\u9fa5]+$/,
                            message: '产品规格不能输入符号'
                        }
                    }
                },
                GenCodeBatch: {
                    validators: {
                        notEmpty: {
                            message: '生码批次不能为空'
                        }
                    }
                },
                StartCode: {
                    validators: {
                        regexp: {
                            regexp: /^[1-9]*[1-9][0-9]*$/,
                            message: '起始码为正整数'
                        },
                        notEmpty: {
                            message: '起始码不能为空'
                        }
                    }
                },
                EndCode: {
                    validators: {
                        regexp: {
                            regexp: /^[1-9]*[1-9][0-9]*$/,
                            message: '结束码为正整数'
                        },
                        notEmpty: {
                            message: '结束码不能为空'
                        }
                    }
                }
            }
        })
    })
</script>